<!DOCTYPE html>
<!-- saved from url=(0066)https://www.17sucai.com/preview/10221/2019-09-03/upload/index.html -->
<html lang="en"><head>
	<title>发布日记</title>
	
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	
	
<!-------------------- 公共头部 --------------------------->
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" name="viewport">
		<meta content="yes" name="apple-mobile-web-app-capable">
		<meta content="black" name="apple-mobile-web-app-status-bar-style">
		<meta content="telephone=no" name="format-detection">
		
		<link rel="stylesheet" type="text/css" href="../static/css/mui.min.css"/>
		<link rel="stylesheet" type="text/css" href="../static/css/mui.previewimage.css"/>
		<link rel="stylesheet" type="text/css" href="../static/css/css.css"/>
		<link rel="stylesheet" type="text/css" href="../static/css/swiper.min.css"/>
		<script type="text/javascript" src="../static/js/swiper.min.js"></script>
		<script type="text/javascript" src="../static/js/mui.min.js"></script>
		<script type="text/javascript" src="../static/js/jquery-1.8.3.min.js"></script>
		<script type="text/javascript" src="../static/js/localImg.js"></script>
		<script type="text/javascript" src="../static/js/mobileImg.js"></script>
		<script type="text/javascript" src="../static/js/mui.zoom.js"></script>
		<script type="text/javascript" src="../static/js/mui.previewimage.js"></script>
<!-- 		<script type="text/javascript" src="//res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script> -->
		
		<style type="text/css">
			.divHeight {
			    width: 100%;
			    height: 5px;
			    background: #f5f5f5;
			    position: relative;
			    overflow: hidden;
			}
			
			.mui-show-loading {  
			    position: fixed;  
			    padding: 5px;  
			    width: 120px;  
			    min-height: 120px;  
			    top: 45%;  
			    left: 50%;  
			    margin-left: -60px;  
			    background: rgba(0, 0, 0, 0.6);  
			    text-align: center;  
			    border-radius: 5px;  
			    color: #FFFFFF;  
			    visibility: hidden;  
			    margin: 0;  
			    z-index: 2000;  
			
			    -webkit-transition-duration: .2s;  
			    transition-duration: .2s;  
			    opacity: 0;  
			    -webkit-transform: scale(0.9) translate(-50%, -50%);  
			    transform: scale(0.9) translate(-50%, -50%);  
			    -webkit-transform-origin: 0 0;  
			    transform-origin: 0 0;  
			}  
			.mui-show-loading.loading-visible {  
			    opacity: 1;  
			    visibility: visible;  
			    -webkit-transform: scale(1) translate(-50%, -50%);  
			    transform: scale(1) translate(-50%, -50%);  
			}  
			.mui-show-loading .mui-spinner{  
			    margin-top: 24px;  
			    width: 36px;  
			    height: 36px;  
			}  
			.mui-show-loading .text {  
			    line-height: 1.6;  
			    font-family: -apple-system-font,"Helvetica Neue",sans-serif;  
			    font-size: 14px;  
			    margin: 10px 0 0;  
			    color: #fff;  
			}  
			
			.mui-show-loading-mask {  
			  position: fixed;  
			  z-index: 1000;  
			  top: 0;  
			  right: 0;  
			  left: 0;  
			  bottom: 0;  
			}  
			.mui-show-loading-mask-hidden{  
			    display: none !important;  
			}
			
			.list-nothing {
			    width: 100%;
			    height: 4rem;
			    display: flex;
			    flex-direction: column;
			    align-items: center;
			    justify-content: center;
			    line-height: 1.01;
			}
			.list-nothing__icon {
			    background: url(../static/img/bg_nothing.png) no-repeat 0 0;
			    background-size: contain;
			    width: 2rem;
			    height: 2rem;
			}
			.list-nothing__text {
			    margin-top: 0.4rem;
			    font-size: 0.2rem;
			    color: #151617;
			}
		</style>
		
		<script type="text/javascript">
			//扩展mui.showLoading  
			(function($, window) {  
			    //显示加载框  
			    $.showLoading = function(message,type) {  
			        if ($.os.plus && type !== 'div') {  
			            $.plusReady(function() {  
			                plus.nativeUI.showWaiting(message);  
			            });  
			        } else {  
			            var html = '';  
			            html += '<i class="mui-spinner mui-spinner-white"></i>';  
			            html += '<p class="text">' + (message || "数据加载中") + '</p>';  
		
			            //遮罩层  
			            var mask=document.getElementsByClassName("mui-show-loading-mask");  
			            if(mask.length==0){  
			                mask = document.createElement('div');  
			                mask.classList.add("mui-show-loading-mask");  
			                document.body.appendChild(mask);  
			                mask.addEventListener("touchmove", function(e){e.stopPropagation();e.preventDefault();});  
			            }else{  
			                mask[0].classList.remove("mui-show-loading-mask-hidden");  
			            }  
			            //加载框  
			            var toast=document.getElementsByClassName("mui-show-loading");  
			            if(toast.length==0){  
			                toast = document.createElement('div');  
			                toast.classList.add("mui-show-loading");  
			                toast.classList.add('loading-visible');  
			                document.body.appendChild(toast);  
			                toast.innerHTML = html;  
			                toast.addEventListener("touchmove", function(e){e.stopPropagation();e.preventDefault();});  
			            }else{  
			                toast[0].innerHTML = html;  
			                toast[0].classList.add("loading-visible");  
			            }  
			        }     
			    };  
		
			    //隐藏加载框  
			      $.hideLoading = function(callback) {  
			        if ($.os.plus) {  
			            $.plusReady(function() {  
			                plus.nativeUI.closeWaiting();  
			            });  
			        }   
			        var mask=document.getElementsByClassName("mui-show-loading-mask");  
			        var toast=document.getElementsByClassName("mui-show-loading");  
			        if(mask.length>0){  
			            mask[0].classList.add("mui-show-loading-mask-hidden");  
			        }  
			        if(toast.length>0){  
			            toast[0].classList.remove("loading-visible");  
			            callback && callback();  
			        }  
			      }  
			})(mui, window);
		</script>
<!-------------------- 公共头部 --------------------------->
		
	
	<link rel="stylesheet" type="text/css" href="../static/css/issue.css"/>
	
</head>
<body>
<section class="aui-flexView">
	<section class="aui-scrollView">
	
		<div class="aui-textarea-wrapper">
			<div class="textarea-block">
				<textarea class="textarea-item" name="content" placeholder="说说此刻的心情..." maxlength="500" spellcheck="false"></textarea>
				<div class="aui-textarea-count" style="font-size: 0.2rem;">
					<span class="textareaInput">0</span> / <span class="textareaTotal">500</span>
				</div>
			</div>
		</div>

		<div class="aui-upload-box">
			<div class="aui-upload-pic"> 
                <span id="chose_pic_btn" >
                    <input type="file" accept="image/*">
                </span>
                <span  class='pic_look' data-file='../static/img/ad-003.png' style="background-image: url('../static/img/ad-003.png')"><em class='delete_pic'></em></span>
			</div>
		</div>
		
		<div style="padding:0.5rem 1rem;" class="aui-main-button" onclick="saveAlbum();">
			<button style="background: #A9A9A9;">仅发布相册</button>
		</div>
		
		<div style="padding:0rem 1rem;" class="aui-main-button" onclick="save();">
			<button>发布日志 / 相册</button>
		</div>
		
	</section>
</section>


<script type="text/javascript">

	$(document).ready(function() {
		var lenInput = $('.textarea-item').val().length;
		$(".textarea-item").keyup(function() {
			lenInput = $(this).val().length;
			if (lenInput > 0 && lenInput <= 300) {
				$('.textareaInput').html(lenInput);
				$('.textarea-btn').attr('disabled', false);
			} else {
				$('.textarea-btn').attr('disabled', true);
			}
		});
	});
	//字数限制500字

	var picArr = new Array();
	$('input:file').localResizeIMG({
		width: 800,
		quality: 1,
		// 图片压缩 默认1 不压缩
		success: function(result) {
			upload(result);
		}
	});
	
	// 删除图片默认显示
	$(document).on('click', '.delete_pic', function(event) {
		var aa = $(this).parents(".pic_look").index();
		picArr.splice(aa, 1);
		$(this).parents(".pic_look").remove();
		console.log(picArr);
	});
	
	
	function upload(result){
		mui.showLoading("正在上传..","div"); 
		var data={pic:result.base64}; 
        $.ajax({
            type: "POST",
            url: '[[${sysUrl}]]/file/upload',
            data: data,
            dataType:"json",
            success: function(data){
            	if(data.meta.success){
            		var img = new Image();
        			img.src = result.base64;
        			var _str = "<span class='pic_look' data-file='"+data.data.filePath+"' style='background-image: url(" + img.src + ")'><em class='delete_pic'></em></span>"
        			$('#chose_pic_btn').before(_str);
        			var _i = picArr.length
        			picArr[_i] = result.base64;
        			console.log(picArr)
                }else{
            	   mui.toast('系统异常...',{ duration:'10', type:'div' });
                }
            	mui.hideLoading(function (){});
             },
             complete :function(XMLHttpRequest, textStatus){
            	 mui.hideLoading(function (){});
             },
             error:function(XMLHttpRequest, textStatus, errorThrown){ 
            	 mui.toast('系统异常...',{ duration:'10', type:'div' });
            	 mui.hideLoading(function (){});
             }
         }); 		
	}
	
	
	function save(){
		if($(".textarea-item").val()==''){
			mui.toast('日记内容不可为空喔',{ duration:'10', type:'div' });
			return;
		}
		var piclook=$(".pic_look");
		var imgs=[];
		for (var i = 0; i < piclook.length; i++) {
			imgs.push($(piclook[i]).data("file"));
		}
        $.ajax({
            type: "POST",
            url: '[[${sysUrl}]]/wensay/share/save',
            data: {
				"text":$(".textarea-item").val(),
				"imgs":imgs.join(","),
				"status":"1"
            },
            dataType:"json",
            success: function(data){
            	if(data.meta.success){
            		mui.toast('发布成功!',{ duration:'10', type:'div' });
            		window.location.href = "[[${sysUrl}]]/wensay/share.html";
                }else{
            	   mui.toast('系统异常...',{ duration:'10', type:'div' });
                }
             },
             complete :function(XMLHttpRequest, textStatus){
            	
             },
             error:function(XMLHttpRequest, textStatus, errorThrown){ 
            	 mui.toast('系统异常...',{ duration:'10', type:'div' });
             }
         }); 		
	}
	
	
	function saveAlbum(){
		var piclook=$(".pic_look");
		var imgs=[];
		for (var i = 0; i < piclook.length; i++) {
			imgs.push($(piclook[i]).data("file"));
		}
		if(imgs.length<=0){
			mui.toast('请先上传照片喔',{ duration:'10', type:'div' });
			return;
		}
        $.ajax({
            type: "POST",
            url: '[[${sysUrl}]]/wensay/share/save',
            data: {
				"text":$(".textarea-item").val(),
				"imgs":imgs.join(","),
				"status":"0"
            },
            dataType:"json",
            success: function(data){
            	if(data.meta.success){
            		mui.toast('发布成功!',{ duration:'10', type:'div' });
            		window.location.href = "[[${sysUrl}]]/wensay/share.html";
                }else{
            	   mui.toast('系统异常...',{ duration:'10', type:'div' });
                }
             },
             complete :function(XMLHttpRequest, textStatus){
            	
             },
             error:function(XMLHttpRequest, textStatus, errorThrown){ 
            	 mui.toast('系统异常...',{ duration:'10', type:'div' });
             }
         }); 		
	}
	
	

	
	
</script>

</body></html>